<?php

/**
 * This is the model class for table "trazadoras.partos".
 *
 * The followings are the available columns in table 'trazadoras.partos':
 * @property integer $id
 * @property integer $id_persona
 * @property string $fecha_parto
 * @property string $fecha_consejeria
 * @property string $apgar
 * @property string $peso
 * @property string $vdrl
 * @property string $antitetanica
 * @property string $fecha_carga
 * @property integer $id_prestacion
 * @property integer $id_tipotrazadora
 *
 * The followings are the available model relations:
 * @property TipoTrazadora $id
 */
class Partos extends CActiveRecord
{
	/**
	 * @return string the associated database table name
	 */
	public function tableName()
	{
		return 'trazadoras.partos';
	}

	/**
	 * @return array validation rules for model attributes.
	 */
	public function rules()
	{
		// NOTE: you should only define rules for those attributes that
		// will receive user inputs.
		return array(
			array('fecha_parto, fecha_carga, id_prestacion', 'required'),
			array('id_persona, id_prestacion, id_tipotrazadora', 'numerical', 'integerOnly'=>true),
			array('apgar', 'length', 'max'=>6),
			array('peso', 'length', 'max'=>12),
			array('vdrl, antitetanica', 'length', 'max'=>1),
			array('fecha_consejeria', 'safe'),
			// The following rule is used by search().
			// @todo Please remove those attributes that should not be searched.
			array('id, id_persona, fecha_parto, fecha_consejeria, apgar, peso, vdrl, antitetanica, fecha_carga, id_prestacion, id_tipotrazadora', 'safe', 'on'=>'search'),
		);
	}

	/**
	 * @return array relational rules.
	 */
	public function relations()
	{
		// NOTE: you may need to adjust the relation name and the related
		// class name for the relations automatically generated below.
		return array(
			'id' => array(self::BELONGS_TO, 'TipoTrazadora', 'id'),
		);
	}

	/**
	 * @return array customized attribute labels (name=>label)
	 */
	public function attributeLabels()
	{
		return array(
			'id' => 'ID',
			'id_persona' => 'Id Persona',
			'fecha_parto' => 'Fecha Parto',
			'fecha_consejeria' => 'Fecha Consejeria',
			'apgar' => 'Apgar',
			'peso' => 'Peso',
			'vdrl' => 'Vdrl',
			'antitetanica' => 'Antitetanica',
			'fecha_carga' => 'Fecha Carga',
			'id_prestacion' => 'Id Prestacion',
			'id_tipotrazadora' => 'Id Tipotrazadora',
		);
	}

	/**
	 * Retrieves a list of models based on the current search/filter conditions.
	 *
	 * Typical usecase:
	 * - Initialize the model fields with values from filter form.
	 * - Execute this method to get CActiveDataProvider instance which will filter
	 * models according to data in model fields.
	 * - Pass data provider to CGridView, CListView or any similar widget.
	 *
	 * @return CActiveDataProvider the data provider that can return the models
	 * based on the search/filter conditions.
	 */
	public function search()
	{
		// @todo Please modify the following code to remove attributes that should not be searched.

		$criteria=new CDbCriteria;

		$criteria->compare('id',$this->id);
		$criteria->compare('id_persona',$this->id_persona);
		$criteria->compare('fecha_parto',$this->fecha_parto,true);
		$criteria->compare('fecha_consejeria',$this->fecha_consejeria,true);
		$criteria->compare('apgar',$this->apgar,true);
		$criteria->compare('peso',$this->peso,true);
		$criteria->compare('vdrl',$this->vdrl,true);
		$criteria->compare('antitetanica',$this->antitetanica,true);
		$criteria->compare('fecha_carga',$this->fecha_carga,true);
		$criteria->compare('id_prestacion',$this->id_prestacion);
		$criteria->compare('id_tipotrazadora',$this->id_tipotrazadora);

		return new CActiveDataProvider($this, array(
			'criteria'=>$criteria,
		));
	}

	/**
	 * Returns the static model of the specified AR class.
	 * Please note that you should have this exact method in all your CActiveRecord descendants!
	 * @param string $className active record class name.
	 * @return Partos the static model class
	 */
	public static function model($className=__CLASS__)
	{
		return parent::model($className);
	}
}
